package test;

/**
 * @author zhoujie
 * @date 2020-10-14
 */
public class ThreadTes {

    private int a=0;

    public int getA() {
        return a;
    }

    public void setA(int a) {
        this.a = a;
    }

    public static void main(String[] args) {
        ThreadTes ta=new ThreadTes();
        Thread t1=new Thread(()->{
            for (int i=0;i<10000;i++){
               ta.setA(ta.getA()+1);
            }
        });

        Thread t2=new Thread(()->{
            for (int i=0;i<10000;i++){
                ta.setA(ta.getA()+1);
            }
        });

        t1.start();
        t2.start();

        try{
            Thread.sleep(2000);
        }catch (Exception e){

        }
        System.out.println(ta.getA());
    }
}
